///////////////////////////////////////////////////////////////////////////////
//
// Licensed under the MIT License
//
// Copyright (c) 2010 Chris Colinsky
// All Rights Reserved
//
// version	0.5
// http://code.google.com/p/sugarcookie/
// http://code.google.com/p/sugarcookie/wiki/License
//
////////////////////////////////////////////////////////////////////////////////

package sugarcookie.components.videoPlayer.vo {
	public class PlayListItem {
		public static const QT:String = "qt";
		public static const FLV:String = "flv";
		public static const F4V:String = "f4v";
		
		private var _uri:String;
		private var _mediaType:String;
		private var _label:String;
		private var _volume:Number = 1;
		
		public function PlayListItem(uri:String,label:String=null) {
			_uri = uri;
			_label = label;
			_mediaType = getMediaType();
		}

		public function get uri():String { return _uri; }
		
		public function get mediaType():String { return _mediaType; }
		public function set mediaType(value:String):void { _mediaType = value; }
		
		public function get label():String { return _label; }
		public function set label(value:String):void { _label = value; }
		
		public function get volume():Number { return _volume; }
		public function set volume(value:Number):void { _volume = value; }
		
		private function getMediaType():String {
			var type:String = null;
			var regex:RegExp = /(\.(mp4|flv|f4v))/i;
			var index:int = _uri.search(regex);
			
			if (index<0) return type;
			
			var ext:String = _uri.substr(index+1);
			if (ext.length<3) return type;
			
			switch (ext.toLowerCase()) {
				case "mp4":
				case "mov":
					type = QT;
					break;
				case "flv":
					type = FLV;
					break;
				case "f4v:":
					type = F4V;
					break;
			}
			
			return type;
		}

	}
}